package morphage.engine;

public class ThresholdLayer extends OperationLayer
{
  public String getName() { return "threshold"; }
  public class Data extends LayerData 
  {
    public final static float LIMIT = 0.4f;
  }
  public LayerData Compute(LayerData in)
  { 
    m_layerData = in;
    double[] data = in.m_image.m_matLum.getData();
    int size = in.m_image.m_matLum.numColumns() * in.m_image.m_matLum.numRows();
    for( int i=0; i<size; i++ )
    {
      /*if( data[i] < Data.LIMIT )
        data[i] = 0.;*/
    }
    /*Raster raster = m_layerData.m_image.getData();
    DataBufferInt dataBuf = (DataBufferInt)raster.getDataBuffer();
    int[] buf = dataBuf.getData();
    Pixel pix = new Pixel();
    for( int i=0; i<buf.length; i++ )
    {
      pix.setColor( buf[i] );
      if( pix.lum() < Data.LIMIT )
      {
        //pix.setColor(0.f, 0.f, 0.f);
        buf[i] = 0;
      }
    }
    in.m_image.setData(raster);*/
    return in; 
  }
}
